package org.extremengine;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.extremengine.common.RigidBody;

/**
 * TODO
 * @author yuxing
 *
 */
public class BodyMap {
	private Map<Object, RigidBody> bodyMap = new HashMap<Object, RigidBody>();

	public void put(Object key, RigidBody body) {

	}

	public int size() {
		return bodyMap.size();
	}

	/**
	 * Traverse registered rigid bodies, DON'T change the map during traversing.
	 * @param callback
	 */
	public void traverseMap(TraverseCallback callback) {
		for (Iterator it = bodyMap.keySet().iterator(); it.hasNext();) {
			Object key = it.next();
			callback.onEachBody(bodyMap.get(key));
		}
	}

	public static abstract class TraverseCallback {
		public abstract boolean onEachBody(RigidBody body);
	}
}
